a = input("请输入一个正整数：")

while not a.isdigit() or int(a) <= 0:
    print("请输入一个合法的正整数!")
    a = input("请输入一个正整数：")

a = int(a)
print(a)
count = 1
while a > 1:
    if a % 2 == 0:
        a //= 2
    else:
        a = a * 3 + 1
    print(a)
    count += 1
else:
    print("此序列长为: {}".format(count))